//package com.poi.java;
//
//
//import org.apache.poi.xwpf.usermodel.*;
//
//
//import java.io.*;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.Set;
//
///**
// * @Description:
// * @Auther:
// * @Date: 2023/6/20 10:42
// */
//public class DD {
//
//    public static void main(String[] args) throws IOException {
//        FileInputStream fis = new FileInputStream("D:\\projectsd\\java\\src\\main\\resources\\word\\市场比较及基准地价.docx");
//        XWPFDocument document = new XWPFDocument(fis);
//        Map<String, Object> map = new HashMap<>();
//
//        map.put("{{@securities_address}}", new PictureRenderData(450, 300, "D:\\projectsd\\java\\src\\main\\resources\\img.png"));
//
//        String placeholder = "#delegate_name#";
//        String replacement = "111";
//
//        for (XWPFParagraph paragraph : document.getParagraphs()) {
//            List<XWPFRun> runs = paragraph.getRuns();
//            for (XWPFRun run : runs) {
//                String text = run.getText(0);
//                if (text != null && text.contains(placeholder)) {
//                    text = text.replace(placeholder, replacement);
//                    run.setText(text, 0);
//                }
//            }
//        }
//
//        map.put("#code#","123");
//        List<XWPFFooter> footerList = document.getFooterList();
//        Set<String> set = map.keySet();
//        for (XWPFFooter xwpfFooter : footerList) {
//            List<XWPFParagraph> paragraphs = xwpfFooter.getParagraphs();
//            for (XWPFParagraph paragraph : paragraphs) {
//                List<XWPFRun> runs = paragraph.getRuns();
//                for (int i = 0; i < runs.size(); i++) {
//                    for (String s : set) {
//                        if (runs.get(i).getText(runs.get(i).getTextPosition()) != null &&
//                                runs.get(i).getText(runs.get(i).getTextPosition()).contains(s)) {
//                            String replace = runs.get(i).getText(runs.get(i).getTextPosition()).replace(s, map.get(s).toString());
//                            runs.get(i).setText(replace, 0);
//                        }
//                    }
//                }
//            }
//        }
////        try {
////            // 图片的处理
////            PictureRenderData pictureRenderData = Pictures.ofStream(new FileInputStream("d:\\zhangsan.jpg"), PictureType.PNG)
////                    .size(102, 126).create();
////        } catch (FileNotFoundException e) {
////            e.printStackTrace();
////        }
//
//
//
//
//        FileOutputStream fos = new FileOutputStream("D:\\projectsd\\java\\src\\main\\resources\\word\\newword\\temp.doc");
//        document.write(fos);
//        fos.close();
//
//        document.close();
//        fis.close();
//    }
//    }
